﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace BalloonShop
{
    public static class BalloonShopConfiguration
    {
        //缓存连接字符串
        private static string dbConnectionString;
        //缓存数据提供器名称
        private static string dbProviderName;
        //保存每页面的商品数量
        private readonly static int productsPerPage;
        //保存商品列表中商品描述长度
        private readonly static int productDescriptionLength;
        //保存商店的名称
        private readonly static string siteName;

        static BalloonShopConfiguration()
        {
            dbConnectionString = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ConnectionString;
            dbProviderName = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ProviderName;
            productsPerPage = System.Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);
            productDescriptionLength = System.Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]);
            siteName = ConfigurationManager.AppSettings["SiteName"];
        }
        //返回针对BalloonShop数据库的连接字符串
        public static string DbConnectionString
        {
            get {
                return dbConnectionString;
            }
        }
        //返回数据供应商名称
        public static string DbProviderName
        {
            get 
            {
                return dbProviderName;
            }
        }
        //返回邮件服务器的地址
        public static string MailServer
        {
            get
            {
                return ConfigurationManager.AppSettings["MailServer"];
            }
        }
        //返回电子邮件用户名
        public static string MailUsername
        {
            get
            {
                return ConfigurationManager.AppSettings["MailUsername"];
            }
        }
        //返回电子邮件密码
        public static string MailPassword
        {
            get
            {
                return ConfigurationManager.AppSettings["MailPassword"];
            }
        }
        //返回邮件发件人
        public static string MailFrom
        {
            get
            {
                return ConfigurationManager.AppSettings["MailFrom"];
            }
        }
        //是否发送错误日志
        public static Boolean EnableErrorLogEmail
        {
            get
            {
                return bool.Parse(ConfigurationManager.AppSettings["EnableErrorLogEmail"]);
            }
        }
        //返回发送错误报告的电邮地址
        public static string ErrorLogEmail
        {
            get
            {
                return ConfigurationManager.AppSettings["ErrorLogEmail"];
            }
        }
        //返回每页面的商品数量最大值
        public static int ProductsPerPage
        {
            get
            {
                return productsPerPage;
            }
        }
        //返回商品列表中商品描述长度
        public static int ProductDescriptionLength
        {
            get
            {
                return productDescriptionLength;
            }
        }
        //返回商店的名称
        public static string SiteName
        {
            get
            {
                return siteName;
            }
        }
    }
}